<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home_model extends OC_Model {

    public function get_banners()
    {
    	$this->db->where('b_active', 1);
    	return $this->db->get('banners')->result();
    }

    public function get_articles()
    {
    	$this->db->limit(3);
    	$this->db->order_by('a_id', 'desc');
    	return $this->db->get('articles')->result();
    }

    public function list_articles()
    {

    }


    public function get_widget($id = false)
    {
        if($id) $this->db->where('widget_place',$id);
        $this->db->order_by('widget_order', 'asc');
        return $this->db->get('widget')->result();
    }

    public function get_event()
    {
        $this->db->limit(4);
        $this->db->order_by('e_id', 'desc');
        return $this->db->get('events')->result();
    }

    public function get_recipes()
    {
        $this->db->limit(12);
        $this->db->order_by('r_id', 'desc');
        return $this->db->get('recipes')->result();
    }

     public function get_recipes2()
    {
        $this->db->limit(6,6);
        $this->db->order_by('r_id', 'desc');
        return $this->db->get('recipes')->result();
    }

    public function get_produk()
    {
        $this->db->where('p_hot',1);
        $this->db->order_by('p_id', 'asc');
        return $this->db->get('products')->result();
    }

    public function get_socmed()
    {
        $this->db->order_by('socmed_order', 'asc');
        return $this->db->get('socmed')->result();
    }

    public function get_result_products($keyword)
    {
        $this->db->like('p_name', $keyword);
        $this->db->or_like('p_desc', $keyword);
        return $this->db->get('products')->result();
    }

    public function get_result_recipes($keyword)
    {
        $this->db->like('r_name', $keyword);
        $this->db->or_like('r_desc',$keyword);
        return $this->db->get('recipes')->result();
    }

    public function get_result_events($keyword)
    {
        $this->db->like('e_name', $keyword);
        $this->db->or_like('e_desc',$keyword);
        return $this->db->get('events')->result();
    }

    public function get_result_articles($keyword)
    {
        $this->db->like('a_title', $keyword);
        $this->db->or_like('a_desc',$keyword);
        return $this->db->get('articles')->result();
    }

    public function get_category($table,$id)
    {
        $this->db->order_by($id, 'asc');
        return $this->db->get($table)->result();
    }

    public function get_recent_recipes()
    {
        $this->db->limit(5);
        $this->db->order_by('r_id', 'desc');
        return $this->db->get('recipes')->result();
    }
}

/* End of file home_model.php */
/* Location: ./applications/module_front/home/models/home_model.php */